/*   1:    */ package tt.dz.web.controller.financial;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import com.alibaba.fastjson.serializer.SerializerFeature;
/*   5:    */ import java.util.HashMap;
/*   6:    */ import java.util.Iterator;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import java.util.Set;
/*  10:    */ import javax.annotation.Resource;
/*  11:    */ import javax.servlet.http.HttpServletRequest;
/*  12:    */ import org.springframework.stereotype.Controller;
/*  13:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  14:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  15:    */ import tt.dz.biz.service.order.OrderServiceService;
/*  16:    */ import tt.dz.common.LogUtil;
/*  17:    */ import tt.dz.vo.OrderServiceVO;
/*  18:    */ import tt.dz.vo.ResponseModle;
/*  19:    */ import tt.dz.vo.UserBaseVO;
/*  20:    */ 
/*  21:    */ @Controller
/*  22:    */ public class OrderServiceController
/*  23:    */ {
/*  24:    */   @Resource(name="orderServiceService")
/*  25:    */   private OrderServiceService orderServiceService;
/*  26:    */   
/*  27:    */   @RequestMapping(value={"/listAllOrderService"}, produces={"application/json;charset=UTF-8"})
/*  28:    */   @ResponseBody
/*  29:    */   public String listAllOrderService()
/*  30:    */   {
/*  31: 35 */     ResponseModle responseModle = null;
/*  32:    */     try
/*  33:    */     {
/*  34: 37 */       List<OrderServiceVO> orderServiceList = this.orderServiceService.listAllOrderService();
/*  35: 38 */       OrderServiceVO orderServiceVO = new OrderServiceVO();
/*  36: 39 */       orderServiceVO.setServiceNo("#");
/*  37: 40 */       recursiveSubjcet(orderServiceVO, orderServiceList);
/*  38: 41 */       Iterator<OrderServiceVO> iterator = orderServiceList.iterator();
/*  39: 42 */       OrderServiceVO sourceOrderService = null;
/*  40: 43 */       Map<String, Object> resultMap = new HashMap();
/*  41: 44 */       while (iterator.hasNext())
/*  42:    */       {
/*  43: 45 */         sourceOrderService = (OrderServiceVO)iterator.next();
/*  44: 46 */         resultMap.put(sourceOrderService.getServiceNo(), sourceOrderService);
/*  45:    */       }
/*  46: 48 */       responseModle = new ResponseModle("success", resultMap);
/*  47:    */     }
/*  48:    */     catch (Exception e)
/*  49:    */     {
/*  50: 50 */       LogUtil.error("查询所有订单服务异常", e);
/*  51: 51 */       responseModle = new ResponseModle("error", new HashMap());
/*  52:    */     }
/*  53: 53 */     return JSON.toJSONString(responseModle, new SerializerFeature[] { SerializerFeature.DisableCircularReferenceDetect });
/*  54:    */   }
/*  55:    */   
/*  56:    */   @RequestMapping(value={"/mapAllCostOrderService"}, produces={"application/json;charset=UTF-8"})
/*  57:    */   @ResponseBody
/*  58:    */   public String mapAllCostOrderService()
/*  59:    */   {
/*  60: 63 */     ResponseModle responseModle = null;
/*  61:    */     try
/*  62:    */     {
/*  63: 65 */       List<OrderServiceVO> orderServiceList = this.orderServiceService.listAllCostOrderService();
/*  64: 66 */       Iterator<OrderServiceVO> iterator = orderServiceList.iterator();
/*  65: 67 */       OrderServiceVO sourceOrderService = null;
/*  66: 68 */       Map<String, Object> resultMap = new HashMap();
/*  67: 69 */       while (iterator.hasNext())
/*  68:    */       {
/*  69: 70 */         sourceOrderService = (OrderServiceVO)iterator.next();
/*  70: 71 */         resultMap.put(sourceOrderService.getServiceNo(), sourceOrderService);
/*  71:    */       }
/*  72: 73 */       responseModle = new ResponseModle("success", resultMap);
/*  73:    */     }
/*  74:    */     catch (Exception e)
/*  75:    */     {
/*  76: 75 */       LogUtil.error("查询所有成本类订单服务异常", e);
/*  77: 76 */       responseModle = new ResponseModle("error", new HashMap());
/*  78:    */     }
/*  79: 78 */     return JSON.toJSONString(responseModle, new SerializerFeature[] { SerializerFeature.DisableCircularReferenceDetect });
/*  80:    */   }
/*  81:    */   
/*  82:    */   @RequestMapping(value={"/queryUnAllotOrderService"}, produces={"application/json;charset=UTF-8"})
/*  83:    */   @ResponseBody
/*  84:    */   public String queryUnAllotOrderService(HttpServletRequest request)
/*  85:    */   {
/*  86: 88 */     ResponseModle responseModle = null;
/*  87:    */     try
/*  88:    */     {
/*  89: 90 */       UserBaseVO userBaseVO = (UserBaseVO)JSON.parseObject(request.getParameter("userBaseVO"), UserBaseVO.class);
/*  90: 91 */       List<OrderServiceVO> orderServiceList = this.orderServiceService.queryUnAllotOrderService(userBaseVO);
/*  91: 92 */       responseModle = new ResponseModle("success", orderServiceList);
/*  92:    */     }
/*  93:    */     catch (Exception e)
/*  94:    */     {
/*  95: 94 */       LogUtil.error("查询当前用户可分配的服务列表异常", e);
/*  96: 95 */       responseModle = new ResponseModle("error", new HashMap());
/*  97:    */     }
/*  98: 97 */     return JSON.toJSONString(responseModle, new SerializerFeature[] { SerializerFeature.DisableCircularReferenceDetect });
/*  99:    */   }
/* 100:    */   
/* 101:    */   public void getChildrenSubject(OrderServiceVO orderServiceVO, List<OrderServiceVO> orderServiceList)
/* 102:    */   {
/* 103:101 */     Iterator<OrderServiceVO> iterator = orderServiceList.iterator();
/* 104:102 */     OrderServiceVO sourceOrderService = null;
/* 105:103 */     while (iterator.hasNext())
/* 106:    */     {
/* 107:104 */       sourceOrderService = (OrderServiceVO)iterator.next();
/* 108:105 */       if (sourceOrderService.getParentNo().equals(orderServiceVO.getServiceNo())) {
/* 109:106 */         orderServiceVO.getChildrenOrderService().add(sourceOrderService);
/* 110:    */       }
/* 111:    */     }
/* 112:    */   }
/* 113:    */   
/* 114:    */   public void recursiveSubjcet(OrderServiceVO orderServiceVO, List<OrderServiceVO> orderServiceList)
/* 115:    */   {
/* 116:112 */     getChildrenSubject(orderServiceVO, orderServiceList);
/* 117:113 */     if (orderServiceVO.getChildrenOrderService().size() > 0)
/* 118:    */     {
/* 119:114 */       Iterator<OrderServiceVO> iterator = orderServiceVO.getChildrenOrderService().iterator();
/* 120:115 */       OrderServiceVO sourceOrderService = null;
/* 121:116 */       while (iterator.hasNext())
/* 122:    */       {
/* 123:117 */         sourceOrderService = (OrderServiceVO)iterator.next();
/* 124:118 */         recursiveSubjcet(sourceOrderService, orderServiceList);
/* 125:    */       }
/* 126:    */     }
/* 127:    */   }
/* 128:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.financial.OrderServiceController
 * JD-Core Version:    0.7.0.1
 */